<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="收房合同编号" prop="sfContractNo" label-width="30">
        <el-input
          v-model="queryParams.sfContractNo"
          placeholder="请输入收房合同编号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="业主姓名" prop="ownerName">
        <el-input
          v-model="queryParams.ownerName"
          placeholder="请输入业主姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <br>
      <el-form-item label="小区名称" prop="premiseName">
        <el-input
          v-model="queryParams.premiseName"
          placeholder="请输入小区名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="合同录入时间" prop="conInfoTime" label-width="30">
        <el-date-picker clearable size="small"
                        v-model="queryParams.conInfoTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="选择合同录入时间，">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="contractList">
      <el-table-column label="合同编号" align="center" prop="sfContractNo" />
      <el-table-column label="小区" align="center" prop="premiseName" />
      <el-table-column label="电话" align="center" prop="signUserMobile" />
      <el-table-column label="起租日期" align="center" prop="leaseStartTime" width="180">

      </el-table-column>
      <el-table-column label="结束日期" align="center" prop="leaseEndTime" width="180">

      </el-table-column>

      <el-table-column label="录入时间" align="center" prop="conInfoTime" width="180">

      </el-table-column>
      <el-table-column label="审核日期" align="center" prop="conAudTime" width="180">

      </el-table-column>
      <el-table-column label="业主" align="center" prop="ownerName" />

      <el-table-column label="操作人" align="center" prop="reserve3" />

      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<!--        <el-upload
          class="avatar-uploader"
          action="http://localhost/dev-api/home/contract/csv"
          :show-file-list="false">
         导入还款计划
        </el-upload>-->
        <template slot-scope="s">
        <el-button type="primary" icon="el-icon-search" size="mini" @click="scht(s.row)">生成合同</el-button>
          <el-button @click="previe()">预览</el-button>
        </template>

      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
let Base64 = require('js-base64').Base64
import {
  listContract,
  getContract,
  delContract,
  addContract,
  updateContract,
  shengcht
} from "@/api/houseClosing/contract";

export default {
  name: "Contract",
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      contractList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        sfContractNo: null,
        premiseName: null,
        ownerName: null,
        conInfoTime: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    previe(){
      var url='http://localhost/dev-api/houseClosing/images/index.pdf';
      window.open('http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(url)));
    },
    scht(row){
      console.log("dsdasdsad")
      shengcht(row).then(r=>{
        this.$message.success("操作成功");
      })

    },
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listContract(this.queryParams).then(response => {
        this.contractList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        sfContractNo: null,
        outContractNo: null,
        lastContractId: null,
        lastContractNo: null,
        businessId: null,
        deptId: null,
        deptNo: null,
        premiseName: null,
        houseId: null,
        houseName: null,
        houseType: null,
        houseZsNo: null,
        cqAddress: null,
        ownerId: null,
        ownerName: null,
        signWithOwner: null,
        ownerIdCard: null,
        ownerMobile: null,
        ownerContactAddress: null,
        signUserName: null,
        signUserIdCard: null,
        signUserMobile: null,
        signUserEmergencyPhone: null,
        bankCard: null,
        bankUserName: null,
        bankUserIdCard: null,
        bankId: null,
        bankName: null,
        bankOpen: null,
        leaseStartTime: null,
        leaseEndTime: null,
        monthRent: null,
        depositMoney: null,
        depositType: null,
        paymentType: null,
        conSignTime: null,
        conInfoTime: null,
        conAudTime: null,
        operId: null,
        sfUserId: null,
        sfUserName: null,
        status: 0,
        xyStatus: 0,
        sfLoanFlg: null,
        freezeStatus: 0,
        accountType: null,
        bankCardNumber: null,
        accountName: null,
        bankBranchCodeLh: null,
        bankAccountProvince: null,
        remark: null,
        reserve1: null,
        reserve2: null,
        reserve3: null,
        reserve4: null,
        reserve5: null,
        delFlg: null,
        createUserid: null,
        createTime: null,
        updateUserid: null,
        updateTime: null,
        houseLeaseType: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download('system/contract/export', {
        ...this.queryParams
      }, `system_contract.xlsx`)
    }
  }
};

</script>
